
pkgname=readline
_basever=7.0
_patchlevel=005 #prepare for some patches
pkgver=$_basever.$_patchlevel
pkgrel=1
pkgdesc="GNU readline library"
arch=('x86_64')
url="https://tiswww.case.edu/php/chet/readline/rltop.html"
license=('GPL')
depends=('glibc' 'ncurses')
backup=('etc/inputrc')
options=('!emptydirs')
source=("https://ftp.gnu.org/gnu/readline/readline-$_basever.tar.gz"
        'inputrc')
if [ $_patchlevel -gt 00 ]; then
    for (( p=1; p<=$((10#${_patchlevel})); p++ )); do
        source=(${source[@]} https://ftp.gnu.org/gnu/readline/readline-${_basever}-patches/readline${_basever//./}-$(printf "%03d" $p))
    done
fi
md5sums=('205b03a87fc83dab653b628c59b9fc91'
         '58d54966c1191db45973cb3191ac621a'
         'e299384458a4cbefaaac3f30e9cc2bba'
         'f9071a353e2fd52a91d32667b23715d6'
         '03595464cf0283286a6e07f4f01c4a70'
         '80e29bef54e2164bf9ecca0c8932cf23'
         '2146e694e0f1f67b025790879111c6cb')

build() {
  cd ${pkgname}-${_basever}
  for (( p=1; p<=$((10#${_patchlevel})); p++ )); do
    msg "applying patch readline${_basever//./}-$(printf "%03d" $p)"
    patch -p0 -i $srcdir/readline${_basever//./}-$(printf "%03d" $p)
  done

  # Remove RPATH from shared objects
  sed -i 's|-Wl,-rpath,$(libdir) ||g' support/shobj-conf

  CFLAGS="$CFLAGS -fPIC"

  ./configure --prefix=/usr 
  make SHLIB_LIBS=-lncurses
}

package() {
  cd ${pkgname}-${_basever}
  make DESTDIR=${pkgdir} install
  
  install -Dm644 ${srcdir}/inputrc ${pkgdir}/etc/inputrc
}

